//
//  LXTabbarViewController.swift
//  LXTXShop
//
//  Created by apple on 2018/4/3.
//  Copyright © 2018年 LX. All rights reserved.
//

import UIKit

class LXTabbarViewController: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()
        self.addChildVC(LXDailyPushTableViewController(), title: "每日推荐", image: "lx_common_tab_dailypush_select", selectImage: "lx_common_tab_dailypush_unselect")
        self.addChildVC(LXHomeViewController(viewModel:LXHomeViewModel()), title: "首页", image: "lx_commom_tab_home_unselect", selectImage: "lx_commom_tab_home_select")
        self.addChildVC(LXDiscoverViewController(), title: "发现", image: "lx_common_tab_dailypush_select", selectImage: "lx_common_tab_dailypush_unselect")
        self.addChildVC(LXGroupViewController(), title: "圈子", image: "lx_common_tab_dailypush_select", selectImage: "lx_common_tab_dailypush_unselect")
        self.addChildVC(LXChatViewController(), title: "聊天", image: "lx_common_tab_dailypush_select", selectImage: "lx_common_tab_dailypush_unselect")
    }
    
    fileprivate func addChildVC(_ childController: UIViewController, title: String, image: String , selectImage: String)
    {
        childController.title = title
        
        childController.tabBarItem.image = UIImage(named: image);
        childController.tabBarItem.selectedImage = UIImage(named: selectImage)?.withRenderingMode(UIImageRenderingMode.alwaysOriginal);
        childController.tabBarItem.setTitleTextAttributes([NSAttributedStringKey.foregroundColor:RGB(149,149,149)] , for: UIControlState())
        childController.tabBarItem.setTitleTextAttributes([NSAttributedStringKey.foregroundColor:HOMENAVCOLOR] , for: UIControlState.selected)
        let nav = LXNavigationController(rootViewController:childController)
        self.addChildViewController(nav)
    }
}
